import Http from './Http.js';

export default class User {
    constructor(name, password, signin) {
        this.name = name;
        this.password = password;
        this.loginStatus = false;
        this.signin = signin;
    }

    login(callback) {
        const _this = this;
        Http.ajax({
            url: '/login',
            data: JSON.stringify({
                name: this.name,
                password: this.password,
                signin: this.signin
            }),
            success: function(data) {
                // console.log(data.response);
                _this.loginStatus = JSON.parse(data.response).loginStatus;
                callback && callback(JSON.parse(data.response));
            },
            error: function(data) {
                callback && callback(_this);
            }
        });
    }
}